import { defineStore } from "pinia";
//定义store
export const userStore = defineStore('userStore', {
    state: () => {
        return {
            username: '',
            password: '',
            key:''
        };
    },
    getters: {
        getUsername(state) {
            return state.username;
        },
        getPassword(state) {
            return state.password;
        },
        getKey(state){
            return state.key
        }
    },
    actions: {
        autoLogin() {
            // 从localStorage获取令牌
            const storedKey = localStorage.getItem('key');
            if (storedKey) {
                this.$state.key = storedKey;
            }
        }
    }
});